//
//  mm_selfDefinedTableViewCellOfSubViewForPicRecode.m
//  HondaPro_2
//
//  Created by Eric on 13-7-3.
//  Copyright (c) 2013年 glendale. All rights reserved.
//

#import "mm_selfDefinedTableViewCellOfSubViewForPicRecode.h"

@interface mm_selfDefinedTableViewCellOfSubViewForPicRecode ()

@property(nonatomic,strong)UILabel *indexNumLbl;
@property(nonatomic,strong)UILabel *typeNameLbl;
@property(nonatomic,strong)UILabel *countLbl;
@property(nonatomic,strong)UILabel *remarkLbl;

@end

@implementation mm_selfDefinedTableViewCellOfSubViewForPicRecode

@synthesize arrForKeys = _arrForKeys;
@synthesize dicForLblsOnCell = _dicForLblsOnCell;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        
        self.selectionStyle = UITableViewCellSeparatorStyleNone;
        
        [self initLblsOnCell];
    }
    return self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    [self setNeedsLayout];
}

#pragma mark - create lbls on cell

-(void)initLblsOnCell
{
    CGFloat lblY = 0;
    CGFloat lblH = 50;
    self.indexNumLbl = [self setupCellLabelWithFrame:CGRectMake(40, lblY, 100, lblH)];
    self.typeNameLbl = [self setupCellLabelWithFrame:CGRectMake(141, lblY, 100, lblH)];
    self.countLbl = [self setupCellLabelWithFrame:CGRectMake(242, lblY, 100, lblH)];
    self.remarkLbl = [self setupCellLabelWithFrame:CGRectMake(383, lblY, 200, lblH)];
}

-(UILabel *)setupCellLabelWithFrame:(CGRect)frame{
    UILabel *lbl = [[UILabel alloc] initWithFrame:frame];
    lbl.backgroundColor = [UIColor clearColor];
    lbl.textColor = [UIColor grayColor];
    lbl.font = [UIFont fontWithName:@"ArialMT" size:16];
    lbl.numberOfLines = 2;
    [self.contentView addSubview:lbl];
    return lbl;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    if (self.dataDic) {
        self.indexNumLbl.text = self.dataDic[@"DEFECT_NO"];
        self.typeNameLbl.text = self.dataDic[@"DEFECT_TYPE"];
        self.countLbl.text = [self.dataDic[@"DEFECT_QUANTITY"]stringValue];
        self.remarkLbl.text = self.dataDic[@"DEFECT_REMARK"];
    }else{
        self.indexNumLbl.text = nil;
        self.typeNameLbl.text = nil;
        self.countLbl.text = nil;
        self.remarkLbl.text = nil;
    }
    
}

@end
